void main() {
  Person person = Person('Tom', 20);
  person.sayHello();

  Animal animal = Dog();
  animal.eat();
  animal.sleep();
}

class Person {
  String name;
  int age;

  Person(this.name, this.age);

  void sayHello() {
    print('Hello, my name is $name and I am $age years old.');
  }
}


// 创建一个接口
abstract class Animal {
  void eat();
  void sleep();
}

// 创建一个类，实现接口
class Dog implements Animal {
  @override
  void eat() {
    print('Dog is eating.');
  }
  @override
  void sleep() {
    print('Dog is sleeping.');
  }
}